package org.weishe.fof2;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class FOF implements WritableComparable<FOF> {

	private String user;
	private String friends;
	private int count;// 间接好友数目

	@Override
	public void readFields(DataInput input) throws IOException {
		// this.user
		user = input.readUTF();
		friends = input.readUTF();
		count = input.readInt();
	}

	@Override
	public void write(DataOutput output) throws IOException {
		output.writeUTF(user);
		output.writeUTF(friends);
		output.writeInt(count);
	}

	@Override
	public int compareTo(FOF fof) {
		int r;
		r = this.user.compareTo(fof.getUser());
		if (r == 0) {
			r = this.friends.compareTo(fof.getFriends());
			if (r == 0) {
				r = this.count - fof.getCount();
			}
		}
		return r;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getFriends() {
		return friends;
	}

	public void setFriends(String friends) {
		this.friends = friends;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

}
